<template>
  <div>
    <h6>孙组件</h6>
    <p>来自于祖先组件的数据：{{ data }} - {{ typeof data }}</p>
    <p>来自于祖先组件的数据：{{ msg }} - {{ typeof msg }}</p>
    <p>来自于祖先组件的数据：{{ fn }} - {{ typeof fn }}</p>
    <p>来自于祖先组件的数据：{{ random(0,10) }} - {{ typeof random }}</p>
    <p>来自于祖先组件的数据：{{ title }} - {{ typeof title }}</p>
    <p>来自于祖先组件的数据：{{ fun }} - {{ typeof fun }}</p>
  </div>
</template>

<script setup>
import { inject } from 'vue';

// 引入数据
const data = inject("data");
const msg = inject("msg");
const fn = inject("fn");
const random = inject("random");
const title = inject("title", "默认值");
const fun = inject("fun", ()=>"hi", true);

</script>